package me.jessyan.mvparms.demo.di.module.car;

import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.widget.CustomPopupWindow;

import javax.inject.Named;

import dagger.Module;
import dagger.Provides;

import me.jessyan.mvparms.demo.R;
import me.jessyan.mvparms.demo.mvp.contract.car.PayCostContract;
import me.jessyan.mvparms.demo.mvp.model.car.PayCostModel;
import me.jessyan.mvparms.demo.utils.PerfectClickListener;


@Module
public class PayCostModule {
    private PayCostContract.View view;

    /**
     * 构建PayCostModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public PayCostModule(PayCostContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    PayCostContract.View providePayCostView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    PayCostContract.Model providePayCostModel(PayCostModel model) {
        return model;
    }

    @ActivityScope
    @Provides
    @Named("payTimeoutPop")
    CustomPopupWindow payTimeoutPop(){
        //确定确定兑换此物品?
        View content = LayoutInflater.from(view.getActivity())
                .inflate(R.layout.pop_pay_time_out,null);
        CustomPopupWindow popupWindow = CustomPopupWindow.builder()
                .isFocus(true)
                .isOutsideTouch(true)
                .isWrap(true)
                .contentView(content)
                .customListener(new CustomPopupWindow.CustomPopupWindowListener() {
                    @Override
                    public void initPopupView(View contentView) {
                        contentView.findViewById(R.id.sure_tv).setOnClickListener(new PerfectClickListener() {
                            @Override
                            protected void onNoDoubleClick(View v) {
                                view.dismissPop();
                            }
                        });

                    }
                }).build();
        //PopupWindow全屏显示
        popupWindow.setClippingEnabled(false);
        return popupWindow;
    }

    @ActivityScope
    @Provides
    @Named("selectParkingTicketPop")
    CustomPopupWindow selectParkingTicketPop(){
        //选择优惠券
        View content = LayoutInflater.from(view.getActivity())
                .inflate(R.layout.pop_select_parking_ticket,null);
        CustomPopupWindow popupWindow = CustomPopupWindow.builder()
                .isFocus(true)
                .isOutsideTouch(true)
                .isWrap(true)
                .isWithMatch(true)
                .contentView(content)
                .customListener(new CustomPopupWindow.CustomPopupWindowListener() {
                    @Override
                    public void initPopupView(View contentView) {
                        view.choiceTicketPopInit(contentView);
                    }
                }).build();
        //PopupWindow全屏显示
        popupWindow.setClippingEnabled(false);
        popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        return popupWindow;
    }

}